package com.gitee.freakchicken.dbapi.basic.controller;

import com.gitee.freakchicken.dbapi.basic.service.C_X3VFMpBb;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
@RequestMapping("/system")
public class C_5UFTiNjw {

    @Value("${version}")
    String gf_WHvrUprQ;

    @Value("${dbapi.mode}")
    String gf_IqVwdi6Z;

    @Autowired
    C_X3VFMpBb gf_Sznfb83l;

    @Value("${dbapi.api.context}")
    String gf_E70zZdxE;

    @RequestMapping("/version")
    public String m_4cyeZvjN() {
        return gf_WHvrUprQ;
    }

    @RequestMapping("/mode")
    public String m_j5yNHFjp() {
        String lf_DDvRHd2z = System.getenv("DOCKER");
        if ("true".equals(lf_DDvRHd2z)) {
            return gf_IqVwdi6Z + " in docker";
        } else {
            return gf_IqVwdi6Z;
        }
    }

    @RequestMapping("/getIPPort")
    public String m_JzrT5XM7(HttpServletRequest request) {
        if ("standalone".equals(gf_IqVwdi6Z)) {
            return request.getServerName() + ":" + request.getServerPort() + "/" + gf_E70zZdxE;
        } else if ("cluster".equals(gf_IqVwdi6Z)) {
            return gf_Sznfb83l.m_FN2jvbVf() + "/" + gf_E70zZdxE;
        } else {
            return null;
        }
    }

    @RequestMapping("/getIP")
    public String m_jO6JVPJz(HttpServletRequest request) {
        if ("standalone".equals(gf_IqVwdi6Z)) {
            return request.getServerName() + ":" + request.getServerPort();
        } else if ("cluster".equals(gf_IqVwdi6Z)) {
            return gf_Sznfb83l.m_FN2jvbVf();
        } else {
            return null;
        }
    }
}
